<?php
// +----------------------------------------------------------------------
// | Copyright (c) 2020 All rights reserved.
// +----------------------------------------------------------------------
// | User: Simony <1362229026@qq.com>
// | wechat: Shen86579595
// +----------------------------------------------------------------------


namespace app\common\model\withdraw;

use app\common\model\Base;
use think\facade\Config;

class Withdraw extends Base
{
    protected $name = 'withdraw';

    //提现方式 1 微信 2 支付宝 3银行卡
    public $paymethods = [
        1 => '微信',
        2 => '支付宝',
        3 => '银行卡',
    ];
    //0提现中 1提现成功 2提现失败
    public $states = [
        0 => '审核中',
        1 => '已审核',
        2 => '放款中',
        3 => '提现完成',
        4 => '被拒绝',
    ];

    /**
     * User:Simony
     * Function: 列表
     * @param $condition
     * @param int $page
     * @param string $field
     * @param string $order
     * @return array|\PDOStatement|string|\think\Collection
     * @throws \think\exception\DbException
     * @throws db\exception\DataNotFoundException
     * @throws db\exception\ModelNotFoundException
     */
    public function getWithdrawList($condition = [], $page = 0, $field = '*', $order = 'w.id desc')
    {

        $res = $this->alias('w')
            ->join('member m', 'w.member_id=m.id', 'left')
            ->where($condition)
            ->field($field)
            ->order($order);

        if ($page) {
            $res = $res->paginate($page, false, ['query' => request()->param()]);
            $this->page_info = $res;
            $res = $res->toArray();
            return $res['data'];
        } else {
            return $res->select()->toArray();
        }
    }
}